package com.tdam2014.grupo3.entities;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.json.JSONException;
import org.json.JSONObject;

public class Comment {
	
	private String id;
	private String authorName;
	private Date dateCreated;
	private String text;
	
	public Comment() {
	}
	
	public Comment(JSONObject commentObject) throws JSONException {
		this.id = commentObject.getString("id");
        this.authorName = commentObject.getString("authorname");
        this.dateCreated = new Date(commentObject.optLong("datecreate") * 1000L);
        this.text = commentObject.getString("_content");
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getAuthorName() {
		return authorName;
	}

	public void setAuthorName(String authorName) {
		this.authorName = authorName;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}
	
	public String getDateCreatedDateTime() {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
		return sdf.format(this.dateCreated);
	}
	
	public String getDateCreatedDate() {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		return sdf.format(this.dateCreated);
	}
	
	public String getDateCreatedTime() {
		SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
		return sdf.format(this.dateCreated);
	}
}
